﻿#include<iostream>
using namespace std;

const int MAX = 1000;
const int n = 3;
int arc[n][n] = {
	0, 4, 11,
	6, 0, 2,
	3, MAX, 0
};

void Floyd(int arc[n][n], int dist[n][n]) {	//假设图中最多顶点个数
	int i, j, k;
	for(i = 0; i < n; i++)					//初始化矩阵dist
		for(j = 0; j < n; j++) {
			dist[i][j] = arc[i][j];
		}
	for(k = 0; k < n; k++)					//进行n次迭代
		for(i = 0; i < n; i++)
			for(j = 0; j < n; j++)
				if(dist[i][k] + dist[k][j] < dist[i][j]) {
					dist[i][j] = dist[i][k] + dist[k][j];
				}
}
int main() {
	int dist[n][n] = { 0 };
	Floyd(arc, dist);
	/*
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			cout << dist[i][j];
		}
		cout << endl;
	}
	*/
	int e, k;
	cout << "请输入要求的第几个站点到第几个站点：";
	cin >> e;
	cin >> k;
	cout << "输出第" << e << "站点到第" << k << "站点所需的最小价值:";
	cout << dist[e][k];
	cout << endl;

	system("pause");
	return 0;
}